'''
Created on Oct 9, 2009

@author: yanghoch
'''

import os
import getopt
import sys
from CIsoform import Isoforms

def usage():
    sys.stderr.write( "Working dir is " + os.getcwd() + '\n' )
    print __doc__
    print "usage: ", sys.argv[0]
    print "The 1st ptrs is fileN for isoforms' exons"
    print "The 2st ptrs is the TranSEQ Out"
    sys.exit( 2 )

def main():
    try:
        opts, args = getopt.getopt( sys.argv[1:], 'h', ["help"] )
    except getopt.error:
        usage()
        sys.exit( 2 );
    # process options and argument 
    for o in opts:
        if o in ( "-h", "--help" ):
            usage()
            sys.exit();
    argc = len( args )
    if( argc == 2 ):
        IsoformInexonsFN = args[0]
        TranSEQOut = args[1]
        geneName = os.path.basename( args[0] )
        I = Isoforms( geneName )
        # currently use fixed delimiter to parse files                                 
        I.get_exons_info( IsoformInexonsFN, '.', '_' )
        I.get_expression_info( TranSEQOut, '\t' )
        I.get_junc_info()
        I.summary_Juncs_info()
    else:
        usage()
        print str( argc ) + " args are given"

if __name__ == '__main__':
    main()
